﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PadArrowDisplay : VRUIDisplay {
    public MeshRenderer ForwardArrow;
    public MeshRenderer RightArrow;
    public MeshRenderer LeftArrow;
    public MeshRenderer BackArrow;

    public Color UnTouchColor;
    public Color TouchColor;
    public Color PressColor;
	
	// Update is called once per frame
	void Update () {
        ForwardArrow.material.color = UnTouchColor;
        RightArrow.material.color = UnTouchColor;
        LeftArrow.material.color = UnTouchColor;
        BackArrow.material.color = UnTouchColor;
        if (controller.padTouched)
        {
            Vector2 touchPos = new Vector2(controller.controllerState.rAxis0.x, controller.controllerState.rAxis0.y);
            Color toColor = TouchColor;
            if (controller.padPressed) toColor = PressColor;
            if (Vector2.Angle(touchPos, Vector2.up) < 45) ForwardArrow.material.color = toColor;
            if (Vector2.Angle(touchPos, -Vector2.up) < 45) BackArrow.material.color = toColor;
            if (Vector2.Angle(touchPos, Vector2.right) < 45) RightArrow.material.color = toColor;
            if (Vector2.Angle(touchPos, -Vector2.right) < 45) LeftArrow.material.color = toColor;
        }
	}
}
